import requests


class IHRMDeptManageApi:
    @classmethod
    def add_dept_api(cls, token, add_dept_body):
        add_dept_url = "http://ihrm2-test.itheima.net/api/company/department"
        add_dept_header = {"Authorization": token, "Content-Type": "application/json"}
        add_resp = requests.post(url=add_dept_url, headers=add_dept_header, json=add_dept_body)
        return add_resp

    @classmethod
    def get_dept_api(cls, emp_id, token):
        url = "http://ihrm2-test.itheima.net/api/company/department/" + emp_id
        header = {"Authorization": token}
        resp = requests.get(url=url, headers=header)
        return resp

    @classmethod
    def update_dept_api(cls, emp_id, token, body):
        url = "http://ihrm2-test.itheima.net/api/company/department/" + emp_id
        header = {"Authorization": token, "Content-Type": "application/json"}
        resp = requests.put(url=url, headers=header, json=body)
        return resp

    @classmethod
    def del_dept_api(cls, emp_id, token):
        url = "http://ihrm2-test.itheima.net/api/company/department/" + emp_id
        header = {"Authorization": token}
        resp = requests.delete(url=url, headers=header)
        return resp
